home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Need Unique Id generation.
- Date: 28 Feb 1996 12:09:25 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h2cplINNhsi@anvil.ugrad.cs.ubc.ca>
- References: <4h1v2g$btc@alpha.it.net>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <4h1v2g$btc@alpha.it.net>,
- Antonio Romeo <gema001@pn.itnet.it> wrote:
- >I need a Unique Identifier generation routine on multiple machines.
- >The identifier must be a 32bit long (unsigned long int) number.
- >No two identifier generated on different machines can match.
-
- Pick a number. This should be larger than the expected number of
- machines. Make it a power of two so you can strength reduce the modulo
- operation to bit masking.
-
- Assign a unique _congruence class_ modulo that number to each machine.
- Write a routine that, on any machine, picks identifiers only from that
- congruence class. For example, if the modulus is 32, and the machine "foo" is
- congruence class 3 (modulo 32), it will generate numbers that yield a remainder
- of 3 when divided by 32. I.e. ones with a bit pattern:
-
- xxxxxxxxx00011
-
- Where the x's are the rest of the identifier. The lower portion can be thought
- of as a machine identifier.
-
- >This is different from an hash generation as i don't have
- >any 'imput string for it.
- >A clock based only algorithm is not usefull, as two machines
- >can generate the same UI at the same time.
- >So I need a routine based on clock and some machine identifier too.
- >
- >Rule:
- >1. UIs generated on two machines or in different time must be
- >differento from every UI already used;
-
- Each machine can ensure this. The x's can be randomly obtained from the BSD
- random() function or the standard rand() (which has horrible properties :).
-
- >Thank for your help
-
- You can also write a central ``identifier server''. Clients will send requests
- to this server to obtain a unique identifier. The server will generate a
- network-wide unique ID and send it back as the reply. Of course,then you have
- to deal with:
-
- 1. failure of the server
- 2. failure of clients to return ID's (this should not be a
- problem with such a large ID space).
- --
-
-